<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\Company;

/* @var $this yii\web\View */
/* @var $searchModel common\models\CompanySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '供应商';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="company-index" style="overflow:auto;">

<!--     <h1><?= Html::encode($this->title) ?></h1> -->
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('添加供应商', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'tableOptions' => ['class' => 'table table-striped table-bordered','style'=>'width:auto;max-width:none;'],
        'options' => ['class' => 'grid-view','style'=>'overflow:auto'],
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],

            'id',
            'username',
            'company_name',
            'company_no',
            [
                'attribute' => 'company_type',
                'value' => function ($model, $key, $index, $column) {
                    return Company::itemAlias("company_type", $model->company_type);
                },
                'filter'=>Company::itemAlias("company_type"),
             ],
            [
                'attribute' => 'logo',
                'format' => 'image',
                'value'=>function($model) { return $model->logo.'!s100'; },
            ],
            /*[
                'attribute' => 'province',
                //'value' => 'category.name',
                'value' => 'region.name',
                'filter'=>Company::Provincelist(),
            ],
             [
                'attribute' => 'city',
                //'value' => 'category.name',
                'value' => function ($model, $key, $index, $column) {
                    var_dump(Company::Citylist(10));
                    exit;
                    return Company::Citylist($model->province);
                }'region.name',
                'filter'=>  function($model){ return Company::Citylist($model->province);}
            ],*/
            //'address_detail',
             
             'contact_name',
             'contact_tel',
             'job_title',

             [
                'attribute' => 'status',
                'value' => function ($model, $key, $index, $column) {
                    return Company::itemAlias("status", $model->status);
                },
                'filter'=>Company::itemAlias("status"),
             ],  
             //'remark:ntext',
             'create_time',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
